package com.relsell.tmcprototype;

import android.app.ActionBar;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.text.Html;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.MediaController;
import android.widget.TextView;
import android.widget.VideoView;

import com.relsell.utility.ApplicationVars;
import com.relsell.view.phone.PlayVideo;
import com.relsell.view.phone.RegularLessons;

/**
 * Main activity that will start application
 * 
 * @author admin
 * 
 */

public class MainActivity extends Fragment {

	private Button mRegularLessons;
	private Button mInstructors;
	private TextView status,info;
	ImageView videoImageView;
	private View.OnClickListener regularLessonsListener = new View.OnClickListener() {
		
		@Override
		public void onClick(View v) {  
		 Intent i = new Intent(getActivity(),RegularLessons.class);
         getActivity().startActivityForResult(i,1);
		}
	};
	
    private View.OnClickListener instructorsListener = new View.OnClickListener() {
		
		@Override
		public void onClick(View v) {  
			 ApplicationVars.getInstance().getEmptySliderCallBack().showInstructorsView();
		}
	};
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		View v = inflater.inflate(R.layout.activity_main, container,
				false);
		videoImageView = (ImageView) v.findViewById(R.id.videoImageView);
		status=(TextView) v.findViewById(R.id.textViewStatus);
		info=(TextView) v.findViewById(R.id.textViewInfo);
		ApplicationVars.getInstance().startTestmonialsAnimation(status, info);
		videoImageView.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				Intent i = new Intent(getActivity(),PlayVideo.class);
		        getActivity().startActivityForResult(i,0);
				
			}
		});
		//showVideo();
		return v;

	}
	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		setupActionBar();
		initUI();
		mRegularLessons.setOnClickListener(regularLessonsListener);
		mInstructors.setOnClickListener(instructorsListener);
	}
	

	private void initUI() {
		mRegularLessons  = (Button)getView().findViewById(R.id.btnregularlessons);
		mInstructors = (Button)getView().findViewById(R.id.buttonInstructor);
	}
	
	@Override
	public void onDestroy() {
		super.onDestroy();
		

	}

	private void setupActionBar() {
		ActionBar actionBar = getActivity().getActionBar();
		actionBar.setDisplayShowTitleEnabled(false);
		actionBar.setDisplayUseLogoEnabled(false);
		actionBar.setDisplayHomeAsUpEnabled(false);
		actionBar.setDisplayShowCustomEnabled(true);
		actionBar.setDisplayShowHomeEnabled(true);

		View customNav = LayoutInflater.from(getActivity()).inflate(
				R.layout.cutomizedactionbar, null); // layout which contains
													// your button.
		TextView tv = (TextView) customNav.findViewById(R.id.textView1);
		tv.setText(Html.fromHtml(getString(R.string.actionbar_name)));
		actionBar.setCustomView(customNav);
	}
	
	private void showVideo()
    {
       
        Uri uri = Uri.parse("http://khottal.com/ankur/guitar.3gp");
        MediaController mc = new MediaController(getActivity());
       // videoView.setMediaController(mc);
       // videoView.setVideoURI(uri);
       // videoView.start();
    }

}
